package com.qzsoft.zhjd.server.modules.asphalt.service.impl;

import java.util.List;

import com.qzsoft.zhjd.server.modules.asphalt.service.CollectAsphaltMatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;

import com.qzsoft.zhjd.server.modules.asphalt.entity.CollectAsphaltMatchEntity;
import com.qzsoft.zhjd.server.modules.asphalt.mapper.CollectAsphaltMatchMapper;

/**
 * @ClassName AsphaltMatchServiceImpl
 * @Description 生产配比业务接口实现
 * @author linhuawei
 * @since 2022-02-09
 */
@Service
public class CollectAsphaltMatchServiceImpl implements CollectAsphaltMatchService {

    @Autowired
    private CollectAsphaltMatchMapper collectAsphaltMatchMapper;

    @Override
    public CollectAsphaltMatchEntity getByStationAndCode(String stationCode, String matchCode) {
        if(ObjectUtils.isEmpty(matchCode) || ObjectUtils.isEmpty(stationCode)) {
            return null;
        }
        QueryWrapper<CollectAsphaltMatchEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("match_code", matchCode);
        queryWrapper.eq("station_code", stationCode);
        List<CollectAsphaltMatchEntity> list = collectAsphaltMatchMapper.selectList(queryWrapper);
        if (null == list || 1 != list.size()) {
            return null;
        }
        return list.get(0);
    }

}
